<template>
  <div class="feedback">
    <!-- 反馈问题页面 -->
    <!-- 表格部分 -->
    <div class="tableData">
      <el-table style="width: 100%;margin: 40px 0" :data="tableData">
        <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
        <el-table-column label="店铺id" prop="user_id"></el-table-column>
        <el-table-column label="商户姓名" prop="sv_ul_name"></el-table-column>
        <el-table-column label="联系方式" prop="sv_ul_mobile"></el-table-column>
        <el-table-column label="图片信息">
          <template slot-scope="scope">
            <el-popover placement="right" title trigger="click">
              <img :src="scope.row.picture" :onerror="errorImg" width="400" />
              <img
                slot="reference"
                style="cursor: pointer;"
                :src="scope.row.picture"
                min-width="70"
                height="70"
              />
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column min-width="120" label="反馈问题" prop="userfeedback_content"></el-table-column>
        <el-table-column min-width="160" label="反馈时间" prop="creationdate" :formatter="dateFormat"></el-table-column>
      </el-table>
    </div>
    <!-- 分页器部分 -->
    <Pagination
      :total="total"
      :pageIndex="pageIndex"
      :pageSize="pageSize"
      @handleSizeChange="handleSizeChange"
      @handleCurrentChange="handleCurrentChange"
    ></Pagination>
  </div>
</template>

<script>
import Pagination from "@/components/Pagination";
export default {
  data() {
    return {
      // 筛选
      form: {
        processState: "",
        feedbackTime: "",
        handlingTime: ""
      },
      // 表格数据
      tableData: [],
      search: "",
      artwork: "", // 原图
      errorImg: "", // 图片不存在指向地址
      // 分页器的数据
      total: 0, // 总条数
      pageIndex: 1, // 当前页
      pageSize: 10, // 每页数量
      // 令牌
      myToken: ""
    };
  },
  components: {
    Pagination
  },
  methods: {
    // 获取数据
    getOrderData() {
      this.$api
        .getFeedbackList(this.pageIndex, this.pageSize, this.myToken)
        .then(res => {
          const { dataList, total } = res.values;
          this.total = total;
          if (dataList) {
            this.tableData = dataList.map(v => {
              if (v.picture) {
                v.picture = `http://res.decerp.cc${v.picture}` + "";
                setTimeout(() => {}, 400);
                this.errorImg = `javascript:this.src='/static/noImg.jpg';this.onerror = null`;
              }
              return {
                ...v
              };
            });
          }
        });
    },
    // 分页器的方法
    handleSizeChange(val) {
      this.pageSize = val;
      this.getOrderData();
    },
    handleCurrentChange(val) {
      this.pageIndex = val;
      this.getOrderData();
    },
    //时间格式化
    dateFormat: function(row, column) {
      var date = row[column.property];
      if (date == undefined) {
        return "";
      }
      return this.$moment(date).format("YYYY-MM-DD HH:mm:ss");
    },
    // 表格操作事件
    handleRecall(index, value) {
      if (value.operation === "删除") {
        this.tableData.splice(index, 1);
      } else {
        value.processState = "已处理";
        value.operation = "删除";
      }
    }
  },
  mounted() {
    // 获取令牌
    this.myToken = sessionStorage.getItem("myToken");
    // 初始化列表
    this.getOrderData();
  }
};
</script>

<style lang="less" scoped>
@deep: ~">>>";
.feedback {
  background-color: #fff;
  padding: 20px;
  .search {
    margin-bottom: 20px;
  }
  .userfeedback_content {
    display: block;
    text-align: left;
  }
  // 筛选部分的样式
  .filtrate {
    padding: 5px 10px;
    background-color: #f1f1f1;
    .el-radio-button {
      margin-right: 10px;
    }
  }
  // 修改表格表头样式
  .tableData @{deep} .el-table th {
    background-color: #fafafa;
    color: #252525;
    font-weight: 100;
  }
  // 筛选的每一项
  .filtrate @{deep} .el-form-item {
    margin-bottom: 0;
  }
  // 筛选项的标题
  .filtrate @{deep} .el-form-item__label {
    font-weight: 600;
    color: #000;
  }
  // 筛选项的内容
  .filtrate @{deep} .el-radio-button__inner {
    border: 1px solid #f1f1f1;
    background-color: #f1f1f1;
    font-size: 14px;
    color: #626366;
  }
  // 筛选项选中内容
  .filtrate @{deep} .is-active .el-radio-button__inner {
    background-color: #f1f1f1;
    border: 1px solid #439fff;
    box-shadow: unset;
    border-radius: 4px;
  }
}
</style>